/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            aInspectionRoutePointInfo: {
                points: [],
                inspectionRouteId: '',
                total: 0,
                records: 1,
                routeName: ''
            }
        },
        _initMethod: function () {
            //$that._listInspectionRoutePoints(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('aInspectionRoutePoint','switch', function (_param) {
                $that.aInspectionRoutePointInfo.inspectionRouteId = _param.inspectionRouteId;
                $that._listInspectionRoutePoints(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('aInspectionRoutePoint','listInspectionPoint', function (_param) {
                $that._listInspectionRoutePoints(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            
            vc.on('aInspectionRoutePoint', 'paginationPlus', 'page_event', function (_currentPage) {
                $that._listInspectionRoutePoints(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listInspectionRoutePoints: function (_page, _rows) {
                var param = {
                    params: {
                        page: _page,
                        row: _rows,
                        inspectionRouteId: $that.aInspectionRoutePointInfo.inspectionRouteId
                    }
                };
                //发送get请求
                vc.http.apiGet('/inspectionRoute.listAdminInspectionRoutePoints',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.aInspectionRoutePointInfo.total = _json.total;
                        $that.aInspectionRoutePointInfo.records = _json.records;
                        $that.aInspectionRoutePointInfo.points = _json.inspectionPoints;
                        vc.emit('aInspectionRoutePoint', 'paginationPlus', 'init', {
                            total: $that.aInspectionRoutePointInfo.records,
                            dataCount: $that.aInspectionRoutePointInfo.total,
                            currentPage: _page
                        });
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _goBack: function () {
                vc.emit('inspectionRoute', 'goBack', {});
            }
        }
    });
})(window.vc);